
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工</title>
    <%@include file="/static/js/common.jsp"%>
    <script>
        jQuery.ajaxSettings.traditional = true
        $(function () {
            //渲染表格数据
            $('#employee_dg').datagrid({
                url:'/permission/query.do',
                fitColumns:true,
                fit:true,
                pagination:true,
                toolbar:"#employee_tb",

                rownumbers:true,

                columns:[[
                    {field:'id',title:'编号',width:100},
                    {field:'name',title:'权限名称',width:100},
                    {field:'expression',title:'权限表达式',width:100}

                ]]
            });
        })






        /*删除*/
        function deleteUser() {
            var tr = $('#employee_dg').datagrid("getSelections");
            if (!tr) {
                //没有选中
                $.messager.alert('温馨提示',"至少选中一条数据");
                return;
            }

           var ids = $.map(tr,function (ele) {
                return ele.id
            })
            console.log(ids);
            $.get("/permission/delete.do",{ids:ids},function (data) {
                if (data.success) {
                    $.messager.alert('温馨提示','删除成功','info',function () {


                        $('#employee_dg').datagrid("reload");
                    });
                }
                else{
                    $.messager.alert('温馨提示',data.msg);


                }
            })
        }
        /*刷新*/
        function reloadwin() {
            $('#employee_dg').datagrid("reload");
        }
        /*加载权限*/
        function reloadPermissions() {
            $.messager.alert('温馨提示',"亲,加载权限可能需要较长的时间,确认加载?","info",function () {
                
            $.get("/permission/reload.do",function (data) {
                if (data.success) {
                    $.messager.alert('温馨提示','加载成功','info',function () {


                        $('#employee_dg').datagrid("reload");
                    });
                }
                else{
                    $.messager.alert('温馨提示',data.msg);


                }
            })
            });
        }



    </script>
</head>
<body>
<table id="employee_dg"></table>
<div id="employee_tb" >

    <a class="easyui-linkbutton" onclick="reloadPermissions()" data-options="iconCls:'icon-save',text:'加载'"></a>
    <a class="easyui-linkbutton" onclick="deleteUser()" data-options="iconCls:'icon-remove',text:'删除'"></a>
    <a class="easyui-linkbutton" onclick="reloadwin()" data-options="iconCls:'icon-reload',text:'刷新'"></a>

</div>
<div id="employee_dig">
    <form id="employee_form" >
        <table align="center" >
            <input type="hidden" name="id">
            <br>
            <br>

            <tr>
                <td>权限名称:</td>
                <td>
                    <input class="easyui-validatebox" type="text" name="name"  />
                </td>
            </tr>

            <tr>
                <td>权限表达式:</td>
                <td>
                    <input class="easyui-validatebox" type="text" name="sn"  />
                </td>
            </tr>


        </table>

    </form>
</div>


</body>
</html>
